package com.smart.service.impl;

import com.github.liaochong.myexcel.core.*;
import com.github.liaochong.myexcel.utils.AttachmentExportUtil;
import com.smart.common.EntranceLock;
import com.smart.common.enums.BooleanEnum;
import com.smart.common.enums.ErrorCode;
import com.smart.common.exception.BusinessException;
import com.smart.common.utils.AssertUtil;
import com.smart.context.SessionContext;
import com.smart.mapper.ManageUserRegistrationMapper;
import com.smart.mapper.ProjectMapper;
import com.smart.mapper.UnitMapper;
import com.smart.model.domain.ManageTempUserRegistrationDO;
import com.smart.model.domain.ManageUserRegistrationDO;
import com.smart.model.domain.ProjectDO;
import com.smart.model.domain.UnitDO;
import com.smart.model.excel.ManageUserRegistrationExcelVo;
import com.smart.model.excel.ManageUserRegistrationImportRequest;
import com.smart.model.vo.DictItemVO;
import com.smart.service.DictItemService;
import com.smart.service.ImportExcelService;
import com.smart.utils.DateUtils;
import com.smart.utils.StringUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.IOUtils;
import org.apache.ibatis.io.Resources;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;

/**
 * @author: zyh
 * @date: 2023-07-23
 */
@Slf4j
@Service
public class ImportExcelServiceImpl implements ImportExcelService {

    @Autowired
    private RedisTemplate redisTemplate;
    @Autowired
    private DictItemService dictItemService;
    @Autowired
    private UnitMapper unitMapper;
    @Autowired
    private ProjectMapper projectMapper;
    @Autowired
    private ManageUserRegistrationMapper userRegistrationMapper;
    @Autowired
    private EntranceLock entranceLock;
    /**
     * excel数据校验
     * @param file
     * @return
     */
    @Override
    public Map<String, Object> excelDataCheck(MultipartFile file) {
        String originalFilename = file.getOriginalFilename();
        String fileExtension = originalFilename.substring(originalFilename.lastIndexOf(".") + 1);
        AssertUtil.assertTrue("xlsx".equals(fileExtension),"请下载导入模板并严格按要求填写");
        // 将InputStream的数据缓存到ByteArrayOutputStream中
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        try (InputStream inputStream = file.getInputStream()){
            byte[] buffer = new byte[1024];
            int length;
            while ((length = inputStream.read(buffer)) != -1) {
                byteArrayOutputStream.write(buffer, 0, length);
            }
            fileVerification(byteArrayOutputStream);
            InputStream repeatableInputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
            List<ManageUserRegistrationImportRequest> dataList = DefaultExcelReader.of(ManageUserRegistrationImportRequest.class)
                    .sheet(0) // 0代表第一个，如果为0，可省略该操作，也可sheet("名称")读取，.csv文件无效
                    .rowFilter(row -> row.getRowNum() >2) // 如无需过滤，可省略该操作，0代表第一行
                    .read(repeatableInputStream);// 可接收inputStream
            if (dataList.size()>0){
                for (int i = 0; i < dataList.size(); i++) {
                    ManageUserRegistrationImportRequest request = dataList.get(i);
                    if (request.getUserName()==null&&request.getIdCard()==null
                            &&request.getJobType()==null&&request.getUserPhone()==null
                            &&request.getAddress()==null&&request.getUnitType()==null
                            &&request.getUnitName()==null&&request.getInoculateNumber()==null
                            &&request.getEntranceTime()==null&&request.getCommute()==null){
                        dataList.remove(i);
                    }
                }
            }
            Map<String, Object> resultMap = new HashMap<>();
            if (CollectionUtils.isEmpty(dataList)){
                resultMap.put("success",false);
                resultMap.put("fileId", null);
                resultMap.put("size", 0);
                return resultMap;
            }
            Map<String,Object> messageMap = beanFilter(dataList);
            List<ManageUserRegistrationExcelVo> messageList = (List<ManageUserRegistrationExcelVo>)messageMap.get("list");
            if (!ObjectUtils.isEmpty(messageList)){
                String fileId = UUID.randomUUID().toString();
                redisTemplate.opsForValue().set(fileId,messageList,3600, TimeUnit.SECONDS);
                List<ManageUserRegistrationExcelVo> vos = messageList.stream().filter(manageUserRegistrationExcelVo -> !ObjectUtils.isEmpty(manageUserRegistrationExcelVo.getMessage())).collect(Collectors.toList());
                if (!ObjectUtils.isEmpty(vos)) {
                    resultMap.put("success",false);
                    resultMap.put("fileId", fileId);
                    resultMap.put("size", messageMap.get("index"));
                    return resultMap;
                }else {
                    Map<String, Long> countMap = messageList.stream()
                            .collect(Collectors.groupingBy(ManageUserRegistrationExcelVo::getJobType, Collectors.counting()));
                    resultMap.put("success", true);
                    resultMap.put("fileId", fileId);
                    resultMap.put("data", countMap);
                    return resultMap;
                }
            }
        }catch (BusinessException b){
            throw new BusinessException(b.getMessage());
        }
        catch (Exception e){
            log.error("数据转换错误->{}",e);
            throw new BusinessException("excel读取失败");
        }
        return new HashMap<>();
    }

    /**
     * 返回错误信息的excel
     * @param response
     */
    @Override
    public void excelMessage(String fileId,HttpServletResponse response) {
        List<ManageUserRegistrationExcelVo> messageList = (List<ManageUserRegistrationExcelVo>)redisTemplate.opsForValue().get(fileId);
        Map<String, Object> map = new HashMap<>();
        map.put("messageList",messageList);
        try (ExcelBuilder excelBuilder = new FreemarkerExcelBuilder()) {
            Workbook workbook = excelBuilder.workbookType(WorkbookType.XLSX)
                    .classpathTemplate("/template/manageUserRegistrationExcel.ftl")
                    .build(map);
            SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
            String format = dateFormat.format(new Date());
            AttachmentExportUtil.export(workbook, "进场人员导入错误提示信息"+format, response);
        } catch (IOException e) {
            log.error("进场人员导入错误提示信息导出失败:{}", e.getMessage());
            throw new BusinessException(ErrorCode.INTER_ERR, "进场人员导入错误提示信息导出失败");
        }
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public Boolean excelImport(String fileId) {
        boolean locked = entranceLock.tryLock(fileId);
        AssertUtil.assertTrue(locked,"正在批量办理入场中,请稍后!");
        try{
            Long projectId = SessionContext.getProjectId();
            List<ManageUserRegistrationExcelVo> messageList = (List<ManageUserRegistrationExcelVo>)redisTemplate.opsForValue().get(fileId);
            List<String> idCards = messageList.stream().map(ManageUserRegistrationExcelVo::getIdCard).collect(Collectors.toList());
            Integer count = userRegistrationMapper.selectLeaveOrNotByIdCards(idCards,projectId);
            AssertUtil.assertTrue(count<1,"该批人员已入场,请勿重复入场");
            List<ManageUserRegistrationDO> collect = messageList.stream().map(b -> {
                String idCard = b.getIdCard();
                ManageUserRegistrationDO user = userRegistrationMapper.selectByIdCard(idCard);
                ManageUserRegistrationDO a = new ManageUserRegistrationDO();
                if (!ObjectUtils.isEmpty(user)){
                    a.setUserName(user.getUserName());
                    a.setUserSex(user.getUserSex());
                    a.setUserNation(user.getUserNation());
                    a.setBeBorn(user.getBeBorn());
                    a.setAddress(user.getAddress());
                    a.setDepartment(user.getDepartment());
                    a.setValidityStart(user.getValidityStart());
                    a.setValidityEnd(user.getValidityEnd());
                    a.setCardType(user.getCardType());
                    a.setIdPhoto(user.getIdPhoto());
                }else {
                    String born = getBorn(b.getIdCard());
                    a.setBeBorn(born);
                    a.setUserName(b.getUserName());
                    a.setAddress(b.getAddress());
                    a.setUserSex(getGender(b.getIdCard()));
                }
                a.setProjectId(b.getProjectId());
                a.setUnitId(b.getUnitId());
                a.setUserPhone(b.getUserPhone());
                a.setIdCard(b.getIdCard());
                a.setUnitProperty(b.getUnitTypeDictCode());
                a.setJobType(b.getJobTypeCode());
                a.setInoculateNumber(b.getInoculateNumber());
                a.setEntranceTime(b.getEntranceTimeDate());
                a.setCommute("是".equals(b.getCommute()) ? 1 : ("否".equals(b.getCommute()) ? 0 : null));
                a.setDeleted(BooleanEnum.FALSE.getCode());
                a.setLeaveOrNot(BooleanEnum.TRUE.getCode());
                a.setCreateUser(SessionContext.getProjectId());
                a.setCreateTime(DateUtils.getNowDate());
                return a;
            }).collect(Collectors.toList());
            userRegistrationMapper.batchInsertManageUserRegistration(collect);
        } finally {
            entranceLock.unlock(fileId);
        }
        return true;
    }

    /**
     * 获取性别
     * @param idCardNumber
     * @return
     */
    public static Integer getGender(String idCardNumber) {
        char genderDigit = idCardNumber.charAt(16);
        int genderNumber = Integer.parseInt(String.valueOf(genderDigit));
        return genderNumber % 2 == 0 ? 0 : 1;
    }

    /**
     * 解析身份证号中的出生日期
     * @param idCardNumber
     * @return
     */
    private static String getBorn(String idCardNumber) {
        String birthDateStr = idCardNumber.substring(6, 14); // 从身份证号中提取出生年月部分
        DateTimeFormatter inputFormatter = DateTimeFormatter.ofPattern("yyyyMMdd");
        LocalDate birthDate = LocalDate.parse(birthDateStr, inputFormatter);
        DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("yyyy年M月d日");
        String formattedBirthDate = birthDate.format(outputFormatter);
        return formattedBirthDate;
    }

    /**
     * 下载导入模板
     * @param response
     */
    @Override
    public ResponseEntity<byte[]> downloadExcelTemplate(HttpServletResponse response) {
        try (InputStream inputStream = Resources.getResourceAsStream("template/template.xlsx")) {
            byte[] data = IOUtils.toByteArray(inputStream);
            HttpHeaders headers = new HttpHeaders();
            headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
            headers.setContentDispositionFormData("attachment", "template.xlsx");
            // 设置文件名和文件类型
            headers.set(HttpHeaders.CONTENT_TYPE, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
            headers.set(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"template.xlsx\"");
            return new ResponseEntity<>(data, headers, HttpStatus.OK);
        } catch (IOException e) {
            log.error("进场批量导入模板下载异常", e);
            return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
        }
    }

    /**
     * 数据校验
     * @param dataList
     * @return  返回错误的excel信息
     */
    private Map<String,Object> beanFilter(List<ManageUserRegistrationImportRequest> dataList) {
        Long projectId = SessionContext.getProjectId();
        List<DictItemVO> userJob = dictItemService.queryDictItemByDictCode("USER_JOB");
        List<DictItemVO> unit = dictItemService.queryDictItemByDictCode("UNIT");
        List<UnitDO> unitDOS = unitMapper.selectByProjectId(projectId).stream().filter(unitDO -> !ObjectUtils.isEmpty(unitDO.getUnitName())
                && !ObjectUtils.isEmpty(unitDO.getUnitDetailName())).collect(Collectors.toList());;
        ProjectDO projectDO = projectMapper.selectDOById(projectId);
        List<String> idCardList = new ArrayList<>();
        List<Map<String, String>> indexMapList = new ArrayList<>();
        List<ManageUserRegistrationExcelVo> list = new ArrayList<>();
        AtomicInteger allMessage = new AtomicInteger(0);
        dataList.stream().forEach(a->{
            StringBuilder stringBuilder = new StringBuilder();
            AtomicInteger index = new AtomicInteger(0);
            Map<String, String> indexMap = new HashMap<>();
            ManageUserRegistrationExcelVo vo = new ManageUserRegistrationExcelVo();
            if (ObjectUtils.isEmpty(a.getUserName())){
                int i = index.addAndGet(1);
                stringBuilder.append(i+".姓名为必填项。<br/>");
            }else {
                if (ObjectUtils.isEmpty(a.getIdCard())){
                    int i = index.addAndGet(1);
                    stringBuilder.append(i+".身份证号为必填项。<br/>");
                }else {
                    boolean idCard = StringUtil.isIdCard(a.getIdCard());
                    if (!idCard){
                        int i = index.addAndGet(1);
                        stringBuilder.append(i+".身份证号格式错误。<br/>");
                    }else {
                        try {
                            getBorn(a.getIdCard());
                        } catch (Exception e) {
                            int i = index.addAndGet(1);
                            stringBuilder.append(i+".身份证号格式错误。<br/>");
                        }
                    }
                }
                if (ObjectUtils.isEmpty(a.getJobType())){
                    vo.setJobTypeCode(null);
                    int i = index.addAndGet(1);
                    stringBuilder.append(i+".职务为必填项。<br/>");
                }else {
                    DictItemVO dictItemVO = userJob.stream().filter(job -> job.getDictItemName().equals(a.getJobType())).findFirst().orElse(null);
                    if (ObjectUtils.isEmpty(dictItemVO)){
                        int i = index.addAndGet(1);
                        stringBuilder.append(i+".职务必须下拉选择，不能随意输入。<br/>");
                    }else {
                        vo.setJobTypeCode(dictItemVO.getDictItemCode());
                    }
                }
                if (ObjectUtils.isEmpty(a.getUserPhone())){
                    int i = index.addAndGet(1);
                    stringBuilder.append(i+".手机号为必填项。<br/>");
                }else {
                    boolean isPhone = StringUtil.isPhoneNumber(a.getUserPhone());
                    if (!isPhone){
                        int i = index.addAndGet(1);
                        stringBuilder.append(i+".手机号输入错误。<br/>");
                    }
                }
                if (ObjectUtils.isEmpty(a.getAddress())){
                    int i = index.addAndGet(1);
                    stringBuilder.append(i+".居住地址为必填项。<br/>");
                }
                if (ObjectUtils.isEmpty(a.getUnitType())){
                    vo.setUnitTypeDictCode(a.getUnitType());
                    int i = index.addAndGet(1);
                    stringBuilder.append(i+".单位性质为必填项。<br/>");
                }else {
                    DictItemVO dictItemVO = unit.stream().filter(b -> b.getDictItemName().equals(a.getUnitType())).findFirst().orElse(null);
                    if (ObjectUtils.isEmpty(dictItemVO)){
                        int i = index.addAndGet(1);
                        stringBuilder.append(i+".单位性质必须下拉选择,不能随意输入。<br/>");
                    }else {
                        vo.setUnitTypeDictCode(dictItemVO.getDictItemCode());
                    }
                }
                if (ObjectUtils.isEmpty(a.getUnitName())){
                    int i = index.addAndGet(1);
                    stringBuilder.append(i+".单位名称为必填项。<br/>");
                }else {
                    if (!"总包单位".equals(a.getUnitType())) {
                        if (!ObjectUtils.isEmpty(unitDOS)) {
                            UnitDO unitDO = unitDOS.stream().filter(c -> (c.getUnitName().equals(a.getUnitName())
                                            || c.getUnitDetailName().equals(a.getUnitName()))
                                            && c.getUnitType().equals(unit.stream().filter(d -> d.getDictItemName().equals(a.getUnitType())).findFirst().orElse(new DictItemVO()).getDictItemCode()))
                                    .findFirst().orElse(null);
                            if (ObjectUtils.isEmpty(unitDO)) {
                                int i = index.addAndGet(1);
                                stringBuilder.append(i + ".单位名称错误，或未创建该单位，请核查修改。<br/>");
                            } else {
                                vo.setUnitId(unitDO.getId());
                            }
                        }else {
                            int i = index.addAndGet(1);
                            stringBuilder.append(i + ".单位名称错误，或未创建该单位，请核查修改。<br/>");
                        }
                    }else {
                        String shigongUnit = projectDO.getShigongUnit();
                        if (!shigongUnit.equals(a.getUnitName())){
                            int i = index.addAndGet(1);
                            stringBuilder.append(i + ".单位名称和总包单位名称不一致，请检查修改。<br/>");
                        }
                    }
                }
                if (ObjectUtils.isEmpty(a.getInoculateNumber())){
                    int i = index.addAndGet(1);
                    stringBuilder.append(i+".新冠疫苗接种针数为必填项。<br/>");
                }else {
                    Long inoculateNumber = a.getInoculateNumber();
                    if (inoculateNumber!=0L&&
                            inoculateNumber!=1L&&
                            inoculateNumber!=2L&&
                            inoculateNumber!=3L&&
                            inoculateNumber!=4L&&
                            inoculateNumber!=5L){
                        int i = index.addAndGet(1);
                        stringBuilder.append(i+".新冠疫苗接种针数填写错误。<br/>");
                    }
                }
                if (ObjectUtils.isEmpty(a.getEntranceTime())){
                    int i = index.addAndGet(1);
                    stringBuilder.append(i+".进场日期为必填项。<br/>");
                }else {
                    String entranceTime = a.getEntranceTime();
                    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
                    if (!entranceTime.matches("\\d{4}-(?:0?[1-9]|1[0-2])-(?:0?[1-9]|[12][0-9]|3[01])")) {
                        // 时间格式不正确的处理逻辑
                        int i = index.addAndGet(1);
                        stringBuilder.append(i + ".进场日期格式不正确。<br/>");
                    } else {
                        // 时间格式正确的处理逻辑
                        try {
                            Date parse = dateFormat.parse(entranceTime);
                            // 获取当前时间的时分秒
                            Date currentTime = new Date();
                            Calendar calendar = Calendar.getInstance();
                            calendar.setTime(currentTime);
                            int hour = calendar.get(Calendar.HOUR_OF_DAY);
                            int minute = calendar.get(Calendar.MINUTE);
                            int second = calendar.get(Calendar.SECOND);

                            // 将时分秒设置到日期中
                            calendar.setTime(parse);
                            calendar.set(Calendar.HOUR_OF_DAY, hour);
                            calendar.set(Calendar.MINUTE, minute);
                            calendar.set(Calendar.SECOND, second);

                            // 获取最终的Date类型数据
                            Date finalDate = calendar.getTime();
                            vo.setEntranceTimeDate(finalDate);
                        } catch (ParseException e) {
                            int i = index.addAndGet(1);
                            stringBuilder.append(i + ".进场日期解析失败。<br/>");
                        }
                    }
                }
                if (ObjectUtils.isEmpty(a.getCommute())){
                    int i = index.addAndGet(1);
                    stringBuilder.append(i+".是否通勤为必填项。<br/>");
                }else {
                    String commute = a.getCommute();
                    if (!"是".equals(commute)&&!"否".equals(commute)){
                        int i = index.addAndGet(1);
                        stringBuilder.append(i+".是否通勤填写错误。<br/>");
                    }
                }
                //身份证查重
                if (indexMapList.size()>0){
                    for(int in = 0;in<indexMapList.size();in++){
                        Map<String, String> stringMap = indexMapList.get(in);
                        if (!ObjectUtils.isEmpty(stringMap.get("idCard"))) {
                            if (indexMapList.get(in).get("idCard").equals(a.getIdCard())){
                                String s = stringMap.get("index");
                                ManageUserRegistrationExcelVo manageUserRegistrationExcelVo = list.get(in);
                                if (!manageUserRegistrationExcelVo.getRepeat()) {
                                    if (!idCardList.contains(a.getIdCard())) {
                                        String message = manageUserRegistrationExcelVo.getMessage();
                                        Integer integer = Integer.valueOf(s) + 1;
                                        index.addAndGet(1);
                                        manageUserRegistrationExcelVo.setMessage(message + integer + ".表格中该人员重复出现。<br/>");
                                        manageUserRegistrationExcelVo.setRepeat(true);
                                        idCardList.add(a.getIdCard());
                                        list.set(in, manageUserRegistrationExcelVo);
                                    }
                                }
                            }
                        }
                    }
                }
                if (!ObjectUtils.isEmpty(a.getIdCard())){
                    ManageUserRegistrationDO  user = userRegistrationMapper.selectByProjectIdAndIdCard(projectId,a.getIdCard());
                    if (!ObjectUtils.isEmpty(user)){
                        int i = index.addAndGet(1);
                        stringBuilder.append(i+".该人员已在场，不能重复办理进场。<br/>");
                    }
                }
            }
            indexMap.put("index",Integer.valueOf(index.get()).toString());
            indexMap.put("idCard",a.getIdCard());
            indexMapList.add(indexMap);
            allMessage.addAndGet(index.get());
            vo.setUserName(a.getUserName());
            vo.setIdCard(a.getIdCard());
            vo.setJobType(a.getJobType());
            vo.setUserPhone(a.getUserPhone());
            vo.setAddress(a.getAddress());
            vo.setUnitType(a.getUnitType());
            vo.setUnitName(a.getUnitName());
            vo.setInoculateNumber(a.getInoculateNumber());
            vo.setEntranceTime(a.getEntranceTime());
            vo.setCommute(a.getCommute());
            String message = stringBuilder.toString();
            vo.setMessage(message);
            vo.setRepeat(false);
            vo.setCreateTime(DateUtils.getNowDate());
            vo.setCreateUser(projectId);
            vo.setDeleted(0);
            vo.setProjectId(projectId);
            list.add(vo);
        });
        Map<String, Object> hashMap = new HashMap<>();
        hashMap.put("index",allMessage.get());
        hashMap.put("list",list);
        return hashMap;
    }

    /**
     * 文件是否为模板文件验证
     * @param byteArrayOutputStream
     * @return
     * @throws IOException
     */
    private void fileVerification(ByteArrayOutputStream byteArrayOutputStream) throws IOException {
        InputStream repeatableInputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
        Workbook workbook = WorkbookFactory.create(repeatableInputStream);
        Sheet sheet = workbook.getSheetAt(0); // 获取第一个Sheet
        int rowCount = sheet.getPhysicalNumberOfRows(); // 获取行数
        List<List<String>> data = new ArrayList<>(); // 存储数据的列表
        // 遍历前三行数据
        for (int i = 0; i < Math.min(rowCount, 3); i++) {
            Row row = sheet.getRow(i);
            List<String> rowData = new ArrayList<>();
            // 遍历每个单元格
            for (Cell cell : row) {
                String cellValue = "";
                switch (cell.getCellType()) {
                    case STRING:
                        cellValue = cell.getStringCellValue();
                        break;
                    default:
                        break;

                }
                if (!"".equals(cellValue)) {
                    rowData.add(cellValue);
                }
            }
            data.add(rowData);
        }
        AssertUtil.assertNotEmpty(data,"请下载导入模板并严格按要求填写");
        AssertUtil.assertTrue(!CollectionUtils.isEmpty(data),"请下载导入模板并严格按要求填写");
        AssertUtil.assertTrue(!ObjectUtils.isEmpty(data.get(0)),"请下载导入模板并严格按要求填写");
        AssertUtil.assertTrue(!ObjectUtils.isEmpty(data.get(1)),"请下载导入模板并严格按要求填写");
        AssertUtil.assertTrue(!ObjectUtils.isEmpty(data.get(2)),"请下载导入模板并严格按要求填写");
        AssertUtil.assertTrue(!ObjectUtils.isEmpty(data.get(0).get(0)),"请下载导入模板并严格按要求填写");
        AssertUtil.assertTrue(!ObjectUtils.isEmpty(data.get(1).get(0)),"请下载导入模板并严格按要求填写");
        AssertUtil.assertTrue(!ObjectUtils.isEmpty(data.get(1).get(1)),"请下载导入模板并严格按要求填写");
        AssertUtil.assertTrue(!ObjectUtils.isEmpty(data.get(2).get(0)),"请下载导入模板并严格按要求填写");
        AssertUtil.assertTrue(!ObjectUtils.isEmpty(data.get(2).get(1)),"请下载导入模板并严格按要求填写");
        AssertUtil.assertTrue(!ObjectUtils.isEmpty(data.get(2).get(2)),"请下载导入模板并严格按要求填写");
        AssertUtil.assertTrue(!ObjectUtils.isEmpty(data.get(2).get(3)),"请下载导入模板并严格按要求填写");
        AssertUtil.assertTrue(!ObjectUtils.isEmpty(data.get(2).get(4)),"请下载导入模板并严格按要求填写");
        AssertUtil.assertTrue(!ObjectUtils.isEmpty(data.get(2).get(5)),"请下载导入模板并严格按要求填写");
        AssertUtil.assertTrue(!ObjectUtils.isEmpty(data.get(2).get(6)),"请下载导入模板并严格按要求填写");
        AssertUtil.assertTrue(!ObjectUtils.isEmpty(data.get(2).get(7)),"请下载导入模板并严格按要求填写");
        AssertUtil.assertTrue(!ObjectUtils.isEmpty(data.get(2).get(8)),"请下载导入模板并严格按要求填写");
        AssertUtil.assertTrue(!ObjectUtils.isEmpty(data.get(2).get(9)),"请下载导入模板并严格按要求填写");
        AssertUtil.assertTrue("大 兴 区 建 筑 工 地 人 员 进 场 批 量 导 入".equals(data.get(0).get(0)),"请下载导入模板并严格按要求填写");
        AssertUtil.assertTrue("人员信息".equals(data.get(1).get(0)),"请下载导入模板并严格按要求填写");
        AssertUtil.assertTrue("进场信息".equals(data.get(1).get(1)),"请下载导入模板并严格按要求填写");
        AssertUtil.assertTrue("姓名".equals(data.get(2).get(0)),"请下载导入模板并严格按要求填写");
        AssertUtil.assertTrue("身份证号".equals(data.get(2).get(1)),"请下载导入模板并严格按要求填写");
        AssertUtil.assertTrue("职务".equals(data.get(2).get(2)),"请下载导入模板并严格按要求填写");
        AssertUtil.assertTrue("手机号".equals(data.get(2).get(3)),"请下载导入模板并严格按要求填写");
        AssertUtil.assertTrue("居住地址".equals(data.get(2).get(4)),"请下载导入模板并严格按要求填写");
        AssertUtil.assertTrue("单位性质".equals(data.get(2).get(5)),"请下载导入模板并严格按要求填写");
        AssertUtil.assertTrue("单位名称".equals(data.get(2).get(6)),"请下载导入模板并严格按要求填写");
        AssertUtil.assertTrue("新冠疫苗接种针数".equals(data.get(2).get(7)),"请下载导入模板并严格按要求填写");
        AssertUtil.assertTrue("进场日期".equals(data.get(2).get(8)),"请下载导入模板并严格按要求填写");
        AssertUtil.assertTrue("是否通勤".equals(data.get(2).get(9)),"请下载导入模板并严格按要求填写");
    }
}
